package com.ojoin.trade.t0loan_core.web.dao.impl;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.t0loan_core.web.dao.TbT0PosTranscationOfLoanTransanctionDao;
import com.ojoin.trade.t0loan_core.web.domain.TbT0PosTranscationOfLoanTransanction;

@Repository
public class TbT0PosTranscationOfLoanTransanctionDaoImpl extends BaseDaoImpl<TbT0PosTranscationOfLoanTransanction> implements TbT0PosTranscationOfLoanTransanctionDao {
	
	public SqlSession getSqlSession() {
		return this.sqlSessionTemplate;
	}
	
	public Integer queryT0PosTranscationCountByLoanTransanctionId(
			int t0loanTransLogId) throws BusinessException {
		String mapMethodName = "queryT0PosTranscationCountByLoanTransanctionId";
		try {
			return getSqlSession().selectOne(getSqlName(mapMethodName),
					t0loanTransLogId);
		} catch (Exception e) {
			throw new DaoException(String.format("查询九盈T+0贷款记录中包含的pos机交易记录集合出错！语句：%s",
					getSqlName(mapMethodName)), e);
		}
	}

	@Override
	public void insertIntoT0PosTranscationOfLoanTransanction(Integer t0loanTransLogId, Integer joinuserid, String transdate)
			throws BusinessException {
		String mapMethodName = "insertIntoT0PosTranscationOfLoanTransanction";
		try {
			HashMap<String, Object> parammap = new HashMap<String, Object>();
			parammap.put("t0loanTransLogId", t0loanTransLogId);
			parammap.put("joinuserid", joinuserid);
			parammap.put("transdate", transdate);
			
			getSqlSession().selectList(getSqlName(mapMethodName),
					parammap);
		} catch (Exception e) {
			throw new DaoException(String.format("批量生成九盈T+0贷款记录中包含的pos机交易记录集合出错！语句：%s",
					getSqlName(mapMethodName)), e);
		}
		
	}
}
